<?php $this->load->view("admin/header"); ?>

<script type="text/javascript" src="js/md5.js"></script>
    <!-- 顶部区域 -->
    <div class="main-container" id="main-container">
        <!-- 头部导航 -->
        <div class="main-content">
            <div class="main-content-inner">
                
                <div class="page-content">
                    <!-- hi sir 这里是 内容区域 -->
<!--                    <h3>修改密码</h3>-->

                        <table>
                            <tr>
                                <td style="width:150px; padding: 10px;">旧密码:</td>
                                <td width="400px"><input type="password" size="40" name="oldpassword" class="input-text" /></td>
                            </tr>
                            <tr>
                                <td style="padding: 10px;">新密码:</td>
                                <td><input type="password" size="40" name="newpass1" class="input-text" /></td>
                            </tr>
                            <tr>
                                <td style="padding: 10px;">确认新密码:</td>
                                <td><input type="password" size="40" name="newpass2" class="input-text" /></td>
                            </tr>
                            
                            
<!--                            <tr>-->
<!--                                <td>名字:</td>-->
<!--                                <td><input type="text" size="40" name="name" value="--><?php //echo $row->name; ?><!--" class="input-text" /></td>-->
<!--                            </tr>-->
<!--                            <tr>-->
<!--                                <td>邮箱:</td>-->
<!--                                <td><input type="text" size="40" name="email" value="--><?php //echo $row->email; ?><!--" class="input-text" /></td>-->
<!--                            </tr>-->
                            <tr>
                                <td></td>
                                <td class="t-left"><input id="btnsubmit" type="submit" class="btn btn-s btn-success" value="提交" name="submit" /></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
            <!-- /.main-content -->
        </div>
        <!-- /.main-container -->
    </div>
    
 <script type="text/javascript">
 	$(function(){
 		function checkPass(pass){ 
			if(pass.length < 8){  return 0; } 
			var ls = 0; 
			if(pass.match(/([a-z])+/)){  ls++; }  
			if(pass.match(/([0-9])+/)){  ls++; }  
			if(pass.match(/([A-Z])+/)){   ls++; }  
			return ls; 
		}  

 		$("#btnsubmit").click(function(){
 			var oldpassword 	= md5($("input[name='oldpassword']").val());
 			var newpass1 	= md5($("input[name='newpass1']").val());
 			var newpass2 	= md5($("input[name='newpass2']").val());
 			//alert(oldpassword+" "+newpass1+" "+newpass2 );
 			if(newpass1!=newpass2){
 				alert("2次输入密码不一样");
 				return;
 			}
// 			if(checkPass($("input[name='newpass1']").val()) < 3){
// 				alert("密码需要大小写加数字，至少8位字符");
// 				return;
// 			}
 			
 			$.ajax({
			    url:"<?php echo site_url("admin/users/changPassword");?>",
			    type:"POST",
			    dataType: "json",
				data: { oldpassword:  oldpassword,newpass:newpass1},
				success: function (data) {
					if(data.success){
						Global.alert("修改成功");
					}else{
						Global.alert(data.msg);
					}
				},             
				error: function (XMLHttpRequest, textStatus, errorThrown) {		
					alert(errorThrown+" "+textStatus);	        
			    }
			});
 		});
 	});
 </script>
 